package pl.elka.simulator.core.configurationCommand.impl;

import java.util.List;

import pl.elka.simulator.core.Position;
import pl.elka.simulator.core.Treasure;
import pl.elka.simulator.core.configurationCommand.ConfigurationCommandType;
import pl.elka.simulator.core.configurationCommand.ICommandParam;
import pl.elka.simulator.core.configurationCommand.IConfigurationCommand;
import pl.elka.simulator.core.configurationCommand.ables.IAbleToConfiguration;
import pl.elka.simulator.core.configurationCommand.ables.IAbleToTreasureConfiguration;

public class AddTreasureConfigurationCommand implements IConfigurationCommand{
private ICommandParam param;
	
	@Override
	public IConfigurationCommand newInstance() {	
		return new AddTreasureConfigurationCommand();
	}

	@Override
	public void setParam(ICommandParam param) {
		this.param = param;
		
	}

	@Override
	public ConfigurationCommandType getType() {		
		return ConfigurationCommandType.AddTreasureConfigurationCommand;
	}

	@Override
	public ICommandParam getParam() {		
		return param;
	}
	@Override
	public void execute(IAbleToConfiguration able){
		IAbleToTreasureConfiguration na = (IAbleToTreasureConfiguration) able;
		
		Position position = CommandUtils.getPosition(this);
		List<Treasure> treasures = na.getTreasures();
		treasures.add(new Treasure(position));
		na.setTreasures(treasures);
	}
}
